<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import= "com.roadmap.struts.action.ActionConst"%>
<%@page import="com.roadmap.common.BaseConst"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String user_ssn_id = (String)request.getSession().getAttribute(ActionConst.Aspirant_Id_In_Session);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/> 
<link href="res/css/layout.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/life.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/widget.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="res/js/util.js"></script>
<script type="text/javascript" src="res/js/func.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/interface/UtilHandler.js"></script>
<script type="text/javascript" src="res/js/widget.js"></script>
<title>查看进度 | roadmap</title>

</head>

<body>
<div id="container">
	<jsp:include page="/admin/myheader.jsp"></jsp:include>
	
	<!-- define the frame for logging on-->
	<div class="mainbody"><div class="manager">
	<jsp:include page="/admin/life/nav_btns.jsp"/>
	
	<!-- middle part: content -->
	<div class="middle-part">
		<div class="section">
			<div id="allGoals" class="chart"></div>		
			<div id="allTasks" class="chart"></div>
		</div>
		
		<div class="section" style="border-top:1px solid #E78F28;margin-top:20px;">
			<div style="margin: 10px; float:left;">
				<label style="margin-right:2px;color:#7F7F7F">选择计划</label>
				<select id="planSelect" class="input-text" style="width:260px;">
					<option>请选择</option>
					<logic:present name="plans">
					<logic:iterate id="plan" name="plans">
					<option value="<bean:write name='plan' property='id'/>"><bean:write name="plan" property="name"/></option>
					</logic:iterate>
					</logic:present>					
				</select>
				<input type="button" class="confirmBtn" value="查看进度" onclick="loadPlanTasksChart();"/>
				<input type="button" class="confirmBtn" value="查看计划" onclick="goToPlan();"/>
			</div>
		</div>
		
		<div class="section">	
			<div id="planTasks" class="chart"></div>		
			<div id="planProgress" class="chart">
			
			</div>
		</div>
		
	</div>
	
	<!-- right part: -->
	<div class="right-part">
	</div>
	
	</div>
	
	<div class="clear-div"></div>
	</div>
	
	<jsp:include page="/res/jsp/footer.jsp"></jsp:include>
</div>

<script type="text/javascript">
var chartContext = "<%=BaseConst.CHART_SERVLET_URL%>";

window.onload = function(){	
	PromptDialog.resize(250, 50);
	PromptDialog.relocate(100, 400);
	
	var uid = "<%=user_ssn_id%>";
	loadAllGoalChart(uid);
	loadAllTaskChart(uid);
}

function loadAllGoalChart(uid){
	var div = $("allGoals");
	RDC.gui.showProgressIn(div);		
	UtilHandler.getChartOfAllGoals(uid, div.clientWidth, div.clientHeight, function(result){
		if(result != null){
			$("allGoals").innerHTML = "<img src='" + chartContext + result + "'/>";
		}
	});
}

function loadAllTaskChart(uid){
	var div = $("allTasks");
	RDC.gui.showProgressIn(div);	
	UtilHandler.getChartOfAllTasks(uid, div.clientWidth, div.clientHeight, function(result){
		if(result != null){
			$("allTasks").innerHTML = "<img src='" + chartContext + result + "'/>";
		}
	});
}

function loadPlanTasksChart(){
	if($("planSelect").selectedIndex > 0){
		var pid = $("planSelect").value;
		var div = $("planTasks");
		RDC.gui.showProgressIn(div);	
		UtilHandler.getChartOfPlanTasks(pid, div.clientWidth, div.clientHeight, function(result){
			if(result != null){
				$("planTasks").innerHTML = "<img src='" + chartContext + result + "'/>";
			}
		});
		RDC.gui.showProgressIn($("planProgress"));
		UtilHandler.getChartOfPlanProgress(pid, 270, 240, function(result){
			if(result != null){
				$("planProgress").innerHTML = "<img src='" + chartContext + result + "'/>";
			}
		});
	}
	else { 
		PromptDialog.show("请选择一项计划");
	}
}

function goToPlan(){
	if($("planSelect").selectedIndex > 0){
		window.location.href = "plan.do?act=view&uid=<%=user_ssn_id%>&id=" + $("planSelect").value;
	}
	else { 
		PromptDialog.show("请选择一项计划");
	}
}

</script>

</body>

</html>
